class Solution
{
public:
    vector<int> findIndices(vector<int> &nums, int indexDifference, int valueDifference)
    {
        int n = nums.size();
        int minIndex = 0;
        int minValue = nums[0];
        int maxIndex = 0;
        int maxValue = nums[0];
        for (int i = indexDifference; i < n; ++i)
        {
            if (nums[i - indexDifference] < minValue)
            {
                minIndex = i - indexDifference;
                minValue = nums[i - indexDifference];
            }
            if (nums[i - indexDifference] > maxValue)
            {
                maxIndex = i - indexDifference;
                maxValue = nums[i - indexDifference];
            }
            if (abs(nums[i] - minValue) >= valueDifference)
            {
                return {minIndex, i};
            }
            else if (abs(nums[i] - maxValue) >= valueDifference)
            {
                return {maxIndex, i};
            }
        }
        return {-1, -1};
    }
};